/**
 * author:Administrator
 * date:2016/2/24
 * desc:TODO
 */
'use strict';


let seq = 1;
let list = {};
class VendorRepoImpl {

  static * genId() {
    return 'vendor_' + (seq++);
  }

  static * find(id) {
    return list[id];
  }

  static *store(vendor) {
    if (!vendor.id) vendor.id = yield VendorRepoImpl.genId();
    list[vendor.id] = vendor;
  }

  /**
   * return pojo list
   * @param uId
   * @returns {*}
   */
  static * findByUid(uId) {
    let ids = Object.keys(list);
    let list = [];
    for (let id of ids) {
      let item = list[id];
      if (item.uId == uId) list.push(item);
    }
    return list;
  }

}
module.exports = VendorRepoImpl;